//项目的全局前置守卫
//1.引入路由
import router from './router';
//引入 cookie  
const whiteList = ["/login"];
import { getCookie } from '@/utils/support.js';

router.beforeEach((to,from,next)=>{
    console.log("触发了",to,from,next);
    if(getCookie("token")){
        if(to.path == "/login"){
            next("/home")
        }else{
            next();
        }
    }else{
        if(whiteList.indexOf(to.path) !=-1){
            next();
        }else{
            next("/login");
        }
    }
    
})
